﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
namespace MvcApplication1.Models
{
    public class MembershipBrand
    {
        private string brandname;
        private string linkaddr;
        private string brandintro;
        private Int64 userid;
        private DateTime registertime;
        private string logo;
        private Int64 itemcount;
        private string brandtitle;
        private string brandkeywords;

        public MembershipBrand()  //model binding need a constructor with empty parameter 
        {

        }
        public MembershipBrand(string brandname, string linkaddr, string brandintro, Int64 userid, DateTime registertime, string logo, Int64 itemcount,string brandtitle,string brandkeywords)
        {
            if (string.IsNullOrWhiteSpace(brandname))
            {
                throw new Exception("brandname couldn't be null");
            }
            else
            {
                this.brandname = brandname;
            }
            if (string.IsNullOrWhiteSpace(linkaddr))
            {
                throw new Exception("brand url could not be null");
            }
            else
            {
                this.linkaddr = linkaddr;
            }
            this.brandintro = brandintro;
            if (registertime != null)
            {
                this.registertime = registertime;
            }
            else
            {
                this.registertime = DateTime.Now;
            }
            if (userid == 0)
            {
                throw new Exception("userID must be vaild");
            }
            else
            {
                this.userid = userid;
            }
            this.logo = logo;
            this.itemcount = itemcount;
            if (string.IsNullOrEmpty(brandtitle) == true)
            {
                this.brandtitle="";
            }
            else
            {
                this.brandtitle=brandtitle;
            }
            if (string.IsNullOrEmpty(brandkeywords) == true)
            {
                this.brandkeywords = "";
            }
            else
            {
                this.brandkeywords = brandkeywords;
            }
        }

        [Required]
        [Display(Name="品牌商城地址")]
        public string linkAddr
        {
            get { return linkaddr; }
            set { linkaddr = value; }
        }

        //[Required]
        [Display(Name="品牌介绍")]
        public string brandIntro
        {
            get { return brandintro; }
            set { brandintro = value; }
        }

        //[Required]
        [Display(Name="品牌LOGO")]
        public string Logo
        {
            get { return logo; }
            set { logo = value; }
        }

        [Display(Name="注册时间")]
        public DateTime RegisterTime
        {
            get { return registertime; }
            set { registertime = value; }
        }

        
        [Display(Name="登录名称")]
        public string brandName
        {
            get { return brandname; }
        }

        [Display(Name="商品总数")]
        public Int64 itemCount
        {
            get { return itemcount; }
        }

        public Int64 userID
        {
            get { return userid; }
        }

        [Display(Name="品牌名称")]
        public string BrandTitle
        {
            get { return brandtitle; }
            set { brandtitle = value; }
        }

        [Display(Name="关键字")]
        public string BrandKeywords
        {
            get { return brandkeywords; }
            set { brandkeywords = value; }
        }
    }
}